<template>
	<div>
		<el-form :model="loginForm" :rules="loginFormRules" ref="loginFormRef" label-width="100px"
			class="loginForm sign-in-form">
			<el-form-item label="邮箱" prop="email">
				<el-input placeholder="Enter Email..." v-model="loginForm.email"></el-input>
			</el-form-item>
			<el-form-item label="密码" prop="passwd">
				<el-input type="password" placeholder="Enter Password..." v-model="loginForm.passwd"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button @click="handleLogin('loginFormRef')" type="primary" class="submit_btn">提交</el-button>
			</el-form-item>
			<div class="tiparea">
			  <p>忘记密码？ <a>立即找回</a></p>
			</div>
		</el-form>
	</div>
</template>

<script lang="ts">
	import { ref, getCurrentInstance } from "vue"
	export default {
		props: {
			loginForm: {
				type: Object,
				required: true
			},
			loginFormRules: {
				type: Object,
				require: true
			}
		},
		setup () {
			const { ctx } = getCurrentInstance()
			const handleLogin = (formName) => {
				ctx.$refs[formName].validate((valid) => {
					if (valid) {
						alert('submit!')
					} else {
						console.log('error submit!!')
						return false
					}
				})
			}
			return { handleLogin }
		}
	}
</script>

<style scoped>
/* form */
.loginForm {
  margin-top: 20px;
  background-color: #fff;
  padding: 20px 40px 20px 20px;
  border-radius: 5px;
  box-shadow: 0px 5px 10px #cccc;
}

.submit-btn {
  width: 100%;
}
.tiparea {
  text-align: right;
  font-size: 12px;
  color: #333;
}
.tiparea p a {
  color: #409eff;
}
</style>